#include "message.h"

#include <QPushButton>

Message::Message(QWidget *parent) :
    QMessageBox(parent)
{
}

//玩家胜利提示
void Message::playerWin()
{
    QMessageBox msg;

    msg.setText("<font color=red>游戏结束！</font>");
    msg.setInformativeText("恭喜，你赢了！");
    msg.exec();
}

//电脑胜利提示
void Message::computerWin()
{
    QMessageBox msg;

    msg.setText("<font color=red>游戏结束！</font>");
    msg.setInformativeText("很遗憾，你输了！\n请继续加油！");
    msg.exec();
}

//刚开始游戏时的提示
bool Message::firstStartWarming()
{
    QMessageBox msgBox;
    msgBox.setWindowTitle("五子棋");
    msgBox.setText("游戏操作规则：");
    msgBox.setInformativeText("按左右上下方向键移动棋子\n按空格键确定落棋子\n禁止在棋盘外按空格\n或使用鼠标单击右键落棋\n你是否接受上述的游戏规则?");

    QPushButton *yesButton = msgBox.addButton(tr("接受"),QMessageBox::YesRole);
    QPushButton *noButton = msgBox.addButton(tr("不接受"),QMessageBox::NoRole);

    msgBox.exec();
    if (msgBox.clickedButton() == yesButton)
    {
        return true;
    }
    else if (msgBox.clickedButton() == noButton)
    {
        return false;
    }


    return false;
}

//没有位置的提示
void Message::noPlace()
{
    QMessageBox msg;

    msg.setText("<font color=red>棋盘已满！</font>");
    msg.setInformativeText("本局不分胜负，继续挑战吧！");
    msg.exec();
}
